package vn.bus.bk.help;

import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.MenuItem;

import vn.bus.bk.R;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

public class HelpRegister extends SherlockFragmentActivity {

    private String[] arrayPlace;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
	// TODO Auto-generated method stub
	super.onCreate(savedInstanceState);
	setContentView(R.layout.help_register);
	getSupportActionBar().setDisplayHomeAsUpEnabled(true);
	getSupportActionBar().setHomeButtonEnabled(true);
	TextView helpRegister = (TextView) findViewById(R.id.tv_help_register);
	arrayPlace = getResources()
		.getStringArray(R.array.array_place_register);

	helpRegister.setText(getString(R.string.help_register));

	final TextView place_register = (TextView) findViewById(R.id.tv_place_register);
	registerForContextMenu(place_register);

	place_register.setOnClickListener(new OnClickListener() {

	    @Override
	    public void onClick(View v) {
		// TODO Auto-generated method stub
		place_register.showContextMenu();
	    }
	});

    }

    @Override
    public void onCreateContextMenu(ContextMenu menu, View v,
	    ContextMenuInfo menuInfo) {
	menu.setHeaderTitle(getString(R.string.announce));
	for (int i = 0; i < arrayPlace.length; i++) {
	    menu.add(0, v.getId(), 0, arrayPlace[i]);
	}
	super.onCreateContextMenu(menu, v, menuInfo);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
	if (item.getItemId() == android.R.id.home) {
	    finish();
	}
	return super.onOptionsItemSelected(item);
    }

}
